package cn.chen.thread;

import java.util.Date;

public class Tools3 {

    public static ThreadLocal2 threadLocal2 = new ThreadLocal2();
}

class ThreadLocal2 extends  ThreadLocal{
    @Override
    protected Object initialValue() {
        return new Date().getTime();
    }
}

class Ru{
    public static void main(String[] args) {
        try {
            for(int i = 0;i < 10;i ++){
                System.out.println("Main线程中取值 = " + Tools3.threadLocal2.get());
                Thread.sleep(100);
            }
            new Th1().start();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}


class Th1 extends Thread{
    @Override
    public void run() {
        try {
            for(int i = 0;i < 10; i ++){
                System.out.println("在ThreadA中取值 = " + Tools3.threadLocal2.get());

                Thread.sleep(100);
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}